Skip to content

Initialize DB with migration#11

Merged
PVince81 merged 2 commits into
masterfrom
doctrine-migration-init
Dec 12, 2016
Merged

Initialize DB with migration#11
PVince81 merged 2 commits into
masterfrom
doctrine-migration-init

Conversation

@PVince81

@PVince81 PVince81 commented Dec 9, 2016

Copy link
Copy Markdown
Contributor

Fixes #10

@CLAassistant

CLAassistant commented Dec 9, 2016

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@PVince81

PVince81 commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

I'm stuck because am unable to create a unique index.
In MDB2 schema we had this:

<index>
    <name>cg_uri_index</name>
    <unique>true</unique>
    <field>
        <name>uri</name>
        <sorting>ascending</sorting>
    </field>
</index>

Now with Doctrine I define it as:

    $table->addUniqueIndex(['uri'], 'cg_uri_index');

But MySQL is not happy:

± % sudo -uwwwrun ./occ app:enable customgroups
                              
  [Doctrine\DBAL\Exception\DriverException]                                                                                                                                                 
  An exception occurred while executing 'CREATE TABLE oc_custom_group (group_id INT UNSIGNED AUTO_INCREMENT NOT NULL, uri TINYTEXT NOT NULL, display_name TINYTEXT NOT NULL, UNIQUE INDEX   
  cg_uri_index (uri), PRIMARY KEY(group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':                                                                           
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length                                                             
                                                                                                                                                                                            

                                                                                                                                 
  [Doctrine\DBAL\Driver\PDOException]                                                                                            
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length  
                                                                                                                                 

                                                                                                                                 
  [PDOException]                                                                                                                 
  SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'uri' used in key specification without a key length  

This says that MySQL requires an explicit key length, basically how many of first characters of the field must be indexed: http://stackoverflow.com/a/1827118

However Doctrine doesn't allow you to pass a length for indices: doctrine/orm#3553 (won't fix as too DB specific)

I was told on IRC to try with varchar, let's find out how to do that...

@PVince81

PVince81 commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

Note that in the MDB2 schema the "uri" column was specified as having the type "text" which is somehow mapped to "TINYTEXT"

@PVince81

PVince81 commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

I changed the column type from "text" to "string" and now the index can be created properly.

It is now possible to enable this app and get the initial DB !

@DeepDiver1975 @VicDeo @jvillafanez please review

@PVince81 PVince81 added this to the 10.0 milestone Dec 9, 2016
@PVince81

PVince81 commented Dec 9, 2016

Copy link
Copy Markdown
Contributor Author

btw, requires owncloud/core#14851 checked out on master for it to work

@PVince81 PVince81 mentioned this pull request Dec 9, 2016
7 tasks
@jvillafanez

Copy link
Copy Markdown
Member

👍

@PVince81
PVince81 merged commit dad0d07 into master Dec 12, 2016
@PVince81
PVince81 deleted the doctrine-migration-init branch December 12, 2016 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants